<template>
  <div class="header-info">
    <!--    {{optionsInfo}}-->
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">区域设置</el-divider>
      </div>
      <el-form-item label="区域高度">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo['areaHeight']"
        />
      </el-form-item>

      <el-form-item label="显示设置" class="column-area">
        <el-checkbox-group
            :min="1"
            :max="2"
            v-model="optionsInfo['checkedList']"
        >
          <el-checkbox
              v-for="item in deptOptions"
              :key="item.value"
              :label="item.value"
          >
            <!--            :disabled="item.value==='deptName'"-->
            {{ item.label }}
          </el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="就诊模式" class="column-area">
        <el-radio-group v-model="optionsInfo['waitPatientType']">
          <el-radio :label="item.value" v-for="item in waitPatientTypeOptions" :key="item.value">
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>

      <template v-if="optionsInfo['waitPatientType']===1">
        <el-form-item label="候诊就诊" class="column-area">
          <el-radio-group v-model="optionsInfo['waitPatientMode']">
            <el-radio :label="item.value" v-for="item in options" :key="item.value">
              {{ item.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
      </template>


      <!--候诊列表的时候才具有开启滚动的机会-->
      <template v-if="optionsInfo['waitPatientType']===2">
        <el-form-item label="是否开启滚动">
          <el-switch v-model="optionsInfo['waiting']['scroll']"/>
        </el-form-item>
        <template v-if="optionsInfo['waiting']['scroll']">
          <el-form-item label="滚动速度" class="column-area">
            <el-input-number
                :min="1"
                :max="4"
                size="small"
                v-model="optionsInfo['waiting']['scrollStep']"
            />
          </el-form-item>

          <el-form-item label="开始滚动人数" class="column-area">
            <el-input-number
                :min="4"
                :max="99"
                size="small"
                v-model="optionsInfo['waiting']['scrollNumber']"
            />
          </el-form-item>
        </template>
        <el-form-item label="候诊列表截取的个数" class="column-area" v-if="optionsInfo['waitPatientType']===2">
          <el-input-number
              :min="1"
              size="small"
              v-model="optionsInfo['waitPatientNumber']"
          />
        </el-form-item>
      </template>
    </div>

    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">就诊设置</el-divider>
      </div>
      <el-form-item label="患者标题" class="column-area">
        <el-input
            size="small"
            v-model="optionsInfo['current']['title']"
        />
      </el-form-item>
      <el-form-item label="患者标题宽度" class="column-area">
        <el-input-number
            size="small"
            v-model="optionsInfo['current']['signWidth']"
        />
      </el-form-item>
      <el-form-item label="患者标题字号" class="column-area">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo['current']['titleFontSize']"
        />
      </el-form-item>
      <el-form-item label="患者背景颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['current']['titleBackgroundColor']"
        />
      </el-form-item>
      <el-form-item label="患者区域颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['current']['areaBackgroundColor']"
        />
      </el-form-item>
      <template v-if="false">
        <el-form-item label="是否开启滚动">
          <el-switch v-model="optionsInfo['current']['scroll']"/>
        </el-form-item>

        <template v-if="optionsInfo['current']['scroll']">
          <el-form-item label="滚动速度" class="column-area">
            <el-input-number
                :min="1"
                :max="4"
                size="small"
                v-model="optionsInfo['current']['scrollStep']"
            />
          </el-form-item>

          <el-form-item label="开始滚动人数" class="column-area">
            <el-input-number
                :min="1"
                :max="99"
                size="small"
                v-model="optionsInfo['current']['scrollNumber']"
            />
          </el-form-item>
        </template>
      </template>
    </div>

    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">候诊设置</el-divider>
      </div>

      <el-form-item label="患者标题" class="column-area">
        <el-input
            size="small"
            v-model="optionsInfo['waiting']['title']"
        />
      </el-form-item>
      <el-form-item label="患者标题宽度" class="column-area">
        <el-input-number
            size="small"
            v-model="optionsInfo['waiting']['signWidth']"
        />
      </el-form-item>
      <el-form-item label="患者标题字号" class="column-area">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo['waiting']['titleFontSize']"
        />
      </el-form-item>
      <el-form-item label="患者背景颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['waiting']['titleBackgroundColor']"
        />
      </el-form-item>
      <el-form-item label="患者区域颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['waiting']['areaBackgroundColor']"
        />
      </el-form-item>
    </div>

    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">顶部设置</el-divider>
      </div>
      <el-form-item label="区域高度" v-if="false">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo['deptInfoHeight']"
        />
      </el-form-item>
      <el-form-item label="背景颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['deptInfoBackgroundColor']"
        />
      </el-form-item>

      <template v-if="false">
        <el-form-item label="科室字号">
          <el-input-number
              :min="0"
              size="small"
              v-model="optionsInfo['deptFontsize']"
          />
        </el-form-item>
        <el-form-item label="科室字体颜色">
          <el-color-picker
              size="small"
              show-alpha
              :predefine="predefineColors"
              v-model="optionsInfo['deptColor']"
          />
        </el-form-item>
        <el-form-item label="诊室字号">
          <el-input-number
              :min="0"
              size="small"
              v-model="optionsInfo['roomFontsize']"
          />
        </el-form-item>
        <el-form-item label="诊室字体颜色">
          <el-color-picker
              size="small"
              show-alpha
              :predefine="predefineColors"
              v-model="optionsInfo['roomColor']"
          />
        </el-form-item>
        <el-form-item label="诊室背景色">
          <el-color-picker
              show-alpha
              size="small"
              :predefine="predefineColors"
              v-model="optionsInfo['roomBackgroundColor']"
          />
        </el-form-item>
      </template>
      <el-form-item label="科室显示" v-if="false">
        <el-switch v-model="optionsInfo['deptShow']"/>
      </el-form-item>
      <el-form-item label="诊室显示" v-if="false">
        <el-switch v-model="optionsInfo['roomShow']"/>
      </el-form-item>

      <!--诊室选中字段-->
      <template v-if="optionsInfo['checkedList'].includes('roomName')">
        <roomNameKeyEditor
            :designer="designer"
            :option-model="optionModel"
            :selected-widget="selectedWidget"
        />
      </template>

      <el-form-item label="诊室高度" v-if="false">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo['roomHeight']"
        />
      </el-form-item>
    </div>
  </div>
</template>

<script>
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import roomNameKeyEditor
  from "@sc/templateDetails/modules/homeRight/property-editor/module/scene-edit/basicInfo/roomNameKey-editor.vue";
import * as types from "@c/public/form-designer/devType/datas-types";

export default {
  name: "DRCPatientInfoConfig-editor",
  components: {roomNameKeyEditor},
  componentName: "DRCPatientInfoConfig-editor",
  mixins: [],

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      constantDic: constantDic,
      optionsInfo:Object(),
      radio: 1,
      options: [
        {
          value: 1,
          label: '叫1等1'
        },
        {
          value: 2,
          label: '叫1等2'
        },
        {
          value: 3,
          label: '叫1等3'
        },
        {
          value: 4,
          label: '叫1等4'
        },
        {
          value: 5,
          label: '叫1等5'
        },
        {
          value: 6,
          label: '叫1等6'
        },
      ],
      checkList: [],
      deptTypeOptions: [
        {
          value: 1,
          label: '科室'
        },
        {
          value: 2,
          label: '号别'
        },
        {
          value: 3,
          label: '诊室'
        }
      ],
      predefineColors: types['predefineColors'],
      waitPatientTypeOptions: [
        {
          value: 1,
          label: '诊室等候'
        },
        {
          value: 2,
          label: '候诊列表'
        }
      ],
      deptOptions: [
        {
          value: 'deptName',
          label: '科室'
        },
        {
          value: 'roomName',
          label: '诊室'
        },
        {
          value: 'registerObjName',
          label: '号别'
        }
      ],
    }
  },

  computed: {
    registerObjNameOptions() {
      return this.$store.getters['templateDetails/getRegisterObjNameOptions']
    }
  },


  methods: {
    handleDept(val) {
      if (val) {
        this.optionsInfo.followDept = false;
      }
    },

    handleChangeType(val) {
      if (val === 1) {
        this.optionsInfo.openScroll = false;
        this.optionsInfo.waitPatientStep = 1;
        this.optionsInfo.waitPatientScrollNumber = 6;
        this.optionsInfo.waitPatientNumber = 6;
      } else if (val === 2) {
        this.optionsInfo.waitMode = 1
      }
    },

    // 科室诊室&号别--科室和好别不能共存
    handleChange(val, row) {
      let value = (row.value);
      let {checkList} = (this.optionsInfo);
      if (value === 1) {
        if (val) {
          this.$lodash.pull(checkList, 2);
        }
      }
      if (value === 2) {
        if (val) {
          this.$lodash.pull(checkList, 1);
        }
      }
    },

    handleFollowDept(val) {
      if (val) {
        this.optionsInfo.deptHide = false;
      }
    }
  },

  watch: {
    // 组件的所有信息
    optionModel: {
      handler: function (val) {
        this.optionsInfo = val[val.config];
      },
      deep: true,
      immediate: true
    }
  }

}
</script>


<style lang="scss" scoped>
.column-area {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
    margin-bottom: 10px;
  }

  :deep(.el-form-item__content) {
    width: 100%;
    margin-left: 0 !important;

    .el-radio-group {
      width: 100%;
      display: flex;
      flex-direction: column;

      .el-radio {
        margin-bottom: 10px;
      }
    }

    .el-checkbox-group{
      display: flex;
      flex-direction: column;
    }

  }

}
</style>